x86/mm: use cache in guest_walk_tables()
authorJan Beulich <jbeulich@suse.com>
Thu, 23 Apr 2020 07:58:04 +0000 (09:58 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 23 Apr 2020 07:58:04 +0000 (09:58 +0200)
commit8e85181cf88f83c4ca289f7273863179b1c20611
tree2a7dc5b784a88223202981431d764025fb1f97f3
parent2efbc2d446b1315de9c6441a4d535b1fb91e1767
x86/mm: use cache in guest_walk_tables()

Emulation requiring device model assistance uses a form of instruction
re-execution, assuming that the second (and any further) pass takes
exactly the same path. This is a valid assumption as far as use of CPU
registers goes (as those can't change without any other instruction
executing in between [1]), but is wrong for memory accesses. In
particular it has been observed that Windows might page out buffers
underneath an instruction currently under emulation (hitting between two
passes). If the first pass translated a linear address successfully, any
subsequent pass needs to do so too, yielding the exact same translation.
To guarantee this, leverage the caching that now backs HVM insn
emulation.

[1] Other than on actual hardware, actions like
    XEN_DOMCTL_sethvmcontext, XEN_DOMCTL_setvcpucontext,
    VCPUOP_initialise, INIT, or SIPI issued against the vCPU can occur
    while the vCPU is blocked waiting for a device model to return data.
    In such cases emulation now gets canceled, though, and hence re-
    execution correctness is unaffected.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <pdurrant@amzn.com>
xen/arch/x86/hvm/emulate.c
xen/arch/x86/mm/guest_walk.c
xen/arch/x86/mm/hap/guest_walk.c
xen/arch/x86/mm/shadow/multi.c
xen/include/asm-x86/guest_pt.h
xen/include/asm-x86/hvm/emulate.h